/**
* ostree_checksum_inplace_from_bytes: (skip)
* @csum: (array fixed-size=32): An binary checksum of length 32
- * @buf: Output location, must be at least 65 bytes in length
+ * @buf: Output location, must be at least OSTREE_SHA256_STRING_LEN+1 bytes in length
*
* Overwrite the contents of @buf with stringified version of @csum.
*/
char *
ostree_checksum_from_bytes (const guchar *csum)
{
- char *ret = g_malloc (65);
+ char *ret = g_malloc (OSTREE_SHA256_STRING_LEN+1);
ostree_checksum_inplace_from_bytes (csum, ret);
return ret;
}
{
GString *path;
- g_assert (strlen (checksum) == 64);
+ g_assert (strlen (checksum) == OSTREE_SHA256_STRING_LEN);
path = g_string_new ("objects/");
int i = 0;
size_t len = strlen (checksum);
- if (len != 64)
+ if (len != OSTREE_SHA256_STRING_LEN)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Invalid rev '%s'", checksum);
*/
#define OSTREE_MAX_RECURSION (256)
+/**
+ * OSTREE_SHA256_DIGEST_LEN:
+ *
+ * Length of a sha256 digest when expressed as raw bytes
+ */
#define OSTREE_SHA256_DIGEST_LEN (32)
+/**
+ * OSTREE_SHA256_STRING_LEN:
+ *
+ * Length of a sha256 digest when expressed as a hexadecimal string
+ */
+#define OSTREE_SHA256_STRING_LEN (64)
+
/**
* OstreeObjectType:
* @OSTREE_OBJECT_TYPE_FILE: Content; regular file, symbolic link
key = g_new (OstreeDevIno, 1);
key->dev = stbuf.st_dev;
key->ino = stbuf.st_ino;
- memcpy (key->checksum, checksum, 65);
+ memcpy (key->checksum, checksum, OSTREE_SHA256_STRING_LEN+1);
g_hash_table_add ((GHashTable*)options->devino_to_csum_cache, key);
}
g_autoptr(GHashTable) dir_contents_checksums = NULL;
g_autoptr(GVariant) serialized_tree = NULL;
g_autofree guchar *contents_csum = NULL;
- char contents_checksum_buf[65];
+ char contents_checksum_buf[OSTREE_SHA256_STRING_LEN+1];
dir_contents_checksums = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify)g_free, (GDestroyNotify)g_free);
g_return_val_if_fail (repo != NULL, NULL);
g_return_val_if_fail (contents_checksum != NULL, NULL);
- g_return_val_if_fail (strlen (contents_checksum) == 64, NULL);
+ g_return_val_if_fail (strlen (contents_checksum) == OSTREE_SHA256_STRING_LEN, NULL);
g_return_val_if_fail (metadata_checksum != NULL, NULL);
- g_return_val_if_fail (strlen (metadata_checksum) == 64, NULL);
+ g_return_val_if_fail (strlen (metadata_checksum) == OSTREE_SHA256_STRING_LEN, NULL);
self = g_object_new (OSTREE_TYPE_REPO_FILE, NULL);
self->repo = g_object_ref (repo);
g_autoptr(GVariant) commit_v = NULL;
g_autoptr(GVariant) tree_contents_csum_v = NULL;
g_autoptr(GVariant) tree_metadata_csum_v = NULL;
- char tree_contents_csum[65];
- char tree_metadata_csum[65];
+ char tree_contents_csum[OSTREE_SHA256_STRING_LEN + 1];
+ char tree_metadata_csum[OSTREE_SHA256_STRING_LEN + 1];
g_return_val_if_fail (repo != NULL, NULL);
g_return_val_if_fail (commit != NULL, NULL);
- g_return_val_if_fail (strlen (commit) == 64, NULL);
+ g_return_val_if_fail (strlen (commit) == OSTREE_SHA256_STRING_LEN, NULL);
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT,
commit, &commit_v, error))
g_autoptr(GVariant) dirs_variant = NULL;
g_autoptr(GVariant) content_csum_v = NULL;
g_autoptr(GVariant) meta_csum_v = NULL;
- char tmp_checksum[65];
+ char tmp_checksum[OSTREE_SHA256_STRING_LEN+1];
GFileAttributeMatcher *matcher = NULL;
if (!ostree_repo_file_ensure_resolved (self, error))
typedef struct {
dev_t dev;
ino_t ino;
- char checksum[65];
+ char checksum[OSTREE_SHA256_STRING_LEN+1];
} OstreeDevIno;
#define OSTREE_REPO_TMPDIR_STAGING "staging-"
}
else if (parent_csum_bytes != NULL && depth > 0)
{
- char parent_checksum[65];
+ char parent_checksum[OSTREE_SHA256_STRING_LEN+1];
gpointer parent_depthp;
int parent_depth;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- /* If the input is longer than 64 chars or contains non-hex chars,
+ /* If the input is longer than OSTREE_SHA256_STRING_LEN chars or contains non-hex chars,
don't bother looking for it as an object */
off = strspn (refspec, hexchars);
- if (off > 64 || refspec[off] != '\0')
+ if (off > OSTREE_SHA256_STRING_LEN || refspec[off] != '\0')
return TRUE;
/* this looks through all objects and adds them to the ref_list if:
{
const char *ref_name = NULL;
g_autoptr(GVariant) csum_v = NULL;
- char tmp_checksum[65];
+ char tmp_checksum[OSTREE_SHA256_STRING_LEN+1];
g_variant_get_child (child, 0, "&s", &ref_name);
{
g_autofree char *buf = g_strconcat (name1, name2, NULL);
GString *out = g_string_new ("");
- char checksum[65];
+ char checksum[OSTREE_SHA256_STRING_LEN+1];
guchar csum[OSTREE_SHA256_DIGEST_LEN];
const char *dash = strchr (buf, '-');
{
guint8 objtype = *checksums_data;
const guint8 *csum = checksums_data + 1;
- char tmp_checksum[65];
+ char tmp_checksum[OSTREE_SHA256_STRING_LEN+1];
if (G_UNLIKELY(!ostree_validate_structureof_objtype (objtype, error)))
goto out;
guint64 size;
guint64 usize;
const guchar *csum;
- char checksum[65];
+ char checksum[OSTREE_SHA256_STRING_LEN+1];
gboolean have_all;
g_autoptr(GInputStream) part_in = NULL;
g_autoptr(GBytes) delta_data = NULL;
OstreeRepoContentBareCommit barecommitstate;
guint64 content_size;
GOutputStream *content_out;
- char checksum[65];
+ char checksum[OSTREE_SHA256_STRING_LEN+1];
char *read_source_object;
int read_source_fd;
gboolean have_obj;
typedef struct {
StaticDeltaExecutionState *state;
- char checksum[65];
+ char checksum[OSTREE_SHA256_STRING_LEN+1];
} StaticDeltaContentWrite;
typedef gboolean (*DispatchOpFunc) (OstreeRepo *repo,
const char *name;
OstreeRepoCommitIterResult state;
guint idx;
- char checksum_content[65];
- char checksum_meta[65];
+ char checksum_content[OSTREE_SHA256_STRING_LEN+1];
+ char checksum_meta[OSTREE_SHA256_STRING_LEN+1];
};
/**
const char *name = dent->d_name;
const char *dot;
OstreeObjectType objtype;
- char buf[65];
+ char buf[OSTREE_SHA256_STRING_LEN+1];
if (strcmp (name, ".") == 0 ||
strcmp (name, "..") == 0)
struct _OstreeRepoCommitTraverseIter {
gboolean initialized;
gpointer dummy[10];
- char dummy_checksum_data[65*2];
+ char dummy_checksum_data[(OSTREE_SHA256_STRING_LEN+1)*2];
};
typedef struct _OstreeRepoCommitTraverseIter OstreeRepoCommitTraverseIter;
csum_bytes = ostree_checksum_bytes_peek_validate (csum_v, &csum_error);
if (csum_error == NULL)
{
- char csum[65];
+ char csum[OSTREE_SHA256_STRING_LEN+1];
ostree_checksum_inplace_from_bytes (csum_bytes, csum);
g_print (" %s\n", csum);